#!/usr/bin/env groovy

pipeline {

    agent any
    // 全局变量
    environment {
        // 项目名称
        NAME = 'oops-server-manager'
        // 目标服务器用户名
        SERVER_USERNAME = 'root'
        // 目标服务器地址
        SERVER_ADDRESS = '120.27.19.106'
    }

    stages {
        stage('Checkout') {
            steps {
                echo 'Checking...'
                checkout scm
                echo 'Checkout successful'
            }
        }

        stage('Build') {
            steps {
                echo 'Building'
                sh "mvn clean package"
                echo 'Build successful'
            }
        }

        /**
         * TODO 生成 project.service 有时间在写
         */
        stage('Generator') {
            steps {
                echo 'Generating'
                echo 'TODO'
                echo 'Generator successful'
            }
        }

        /**
         * TODO 参数化构建暂时先不搞
         */
        stage('Deploy'){
            steps {
                script {
                    env.PROJECT = input message: "选择项目：",
                    ok: '项目',
                    parameters: [
                            choice(name: 'PROJECT', choices: '')
                    ]
                }
            }
        }
    }
    post {
//        always {
//            junit '**/target/*.xml'
//        }
//        failure {
//            mail to: 'team@example.com', subject: 'The Pipeline failed :('
//        }
    }
}
